3.1.8 \(\int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx\) [8]

3.1.8.1 Optimal result
3.1.8.2 Mathematica [A] (verified)
3.1.8.3 Rubi [A] (verified)
3.1.8.4 Maple [A] (verified)
3.1.8.5 Fricas [A] (verification not implemented)
3.1.8.6 Sympy [F]
3.1.8.7 Maxima [F(-2)]
3.1.8.8 Giac [A] (verification not implemented)
3.1.8.9 Mupad [B] (verification not implemented)

3.1.8.1 Optimal result

Integrand size = 15, antiderivative size = 98 \[ \int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx=\frac {2 A \arctan \left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}}-\frac {B \log (1-\sin (x))}{2 (a+b)}+\frac {B \log (1+\sin (x))}{2 (a-b)}-\frac {b B \log (a+b \sin (x))}{a^2-b^2} \]

output
-1/2*B*ln(1-sin(x))/(a+b)+1/2*B*ln(1+sin(x))/(a-b)-b*B*ln(a+b*sin(x))/(a^2 
-b^2)+2*A*arctan((b+a*tan(1/2*x))/(a^2-b^2)^(1/2))/(a^2-b^2)^(1/2)
 
3.1.8.2 Mathematica [A] (verified)

Time = 0.36 (sec) , antiderivative size = 108, normalized size of antiderivative = 1.10 \[ \int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx=\frac {2 A \sqrt {a^2-b^2} \arctan \left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )+B \left ((-a+b) \log \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right )+(a+b) \log \left (\cos \left (\frac {x}{2}\right )+\sin \left (\frac {x}{2}\right )\right )-b \log (a+b \sin (x))\right )}{(a-b) (a+b)} \]

input
Integrate[(A + B*Sec[x])/(a + b*Sin[x]),x]
 
output
(2*A*Sqrt[a^2 - b^2]*ArcTan[(b + a*Tan[x/2])/Sqrt[a^2 - b^2]] + B*((-a + b 
)*Log[Cos[x/2] - Sin[x/2]] + (a + b)*Log[Cos[x/2] + Sin[x/2]] - b*Log[a + 
b*Sin[x]]))/((a - b)*(a + b))
 
3.1.8.3 Rubi [A] (verified)

Time = 0.51 (sec) , antiderivative size = 98, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3042, 4714, 3042, 4901, 2009}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {A+B \sec (x)}{a+b \sin (x)}dx\)

\(\Big \downarrow \) 4714

\(\displaystyle \int \frac {\sec (x) (A \cos (x)+B)}{a+b \sin (x)}dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {A \cos (x)+B}{\cos (x) (a+b \sin (x))}dx\)

\(\Big \downarrow \) 4901

\(\displaystyle \int \left (\frac {A}{a+b \sin (x)}+\frac {B \sec (x)}{a+b \sin (x)}\right )dx\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {2 A \arctan \left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{\sqrt {a^2-b^2}}-\frac {b B \log (a+b \sin (x))}{a^2-b^2}-\frac {B \log (1-\sin (x))}{2 (a+b)}+\frac {B \log (\sin (x)+1)}{2 (a-b)}\)

input
Int[(A + B*Sec[x])/(a + b*Sin[x]),x]
 
output
(2*A*ArcTan[(b + a*Tan[x/2])/Sqrt[a^2 - b^2]])/Sqrt[a^2 - b^2] - (B*Log[1 
- Sin[x]])/(2*(a + b)) + (B*Log[1 + Sin[x]])/(2*(a - b)) - (b*B*Log[a + b* 
Sin[x]])/(a^2 - b^2)
 

3.1.8.3.1 Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4714
Int[(u_)*((A_) + (B_.)*sec[(a_.) + (b_.)*(x_)]), x_Symbol] :> Int[ActivateT 
rig[u]*((B + A*Cos[a + b*x])/Cos[a + b*x]), x] /; FreeQ[{a, b, A, B}, x] && 
 KnownSineIntegrandQ[u, x]
 

rule 4901
Int[u_, x_Symbol] :> With[{v = ExpandTrig[u, x]}, Int[v, x] /; SumQ[v]] /; 
 !InertTrigFreeQ[u]
 
3.1.8.4 Maple [A] (verified)

Time = 0.80 (sec) , antiderivative size = 97, normalized size of antiderivative = 0.99

method result size
parts \(\frac {2 A \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{\sqrt {a^{2}-b^{2}}}+B \left (\frac {\ln \left (1+\sin \left (x \right )\right )}{2 a -2 b}-\frac {\ln \left (\sin \left (x \right )-1\right )}{2 a +2 b}-\frac {b \ln \left (a +b \sin \left (x \right )\right )}{\left (a -b \right ) \left (a +b \right )}\right )\) \(97\)
default \(\frac {-B b \ln \left (a \left (\tan ^{2}\left (\frac {x}{2}\right )\right )+2 b \tan \left (\frac {x}{2}\right )+a \right )+\frac {2 \left (A \,a^{2}-A \,b^{2}\right ) \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{\sqrt {a^{2}-b^{2}}}}{\left (a -b \right ) \left (a +b \right )}-\frac {2 B \ln \left (\tan \left (\frac {x}{2}\right )-1\right )}{2 a +2 b}+\frac {2 B \ln \left (\tan \left (\frac {x}{2}\right )+1\right )}{2 a -2 b}\) \(126\)
risch \(\frac {2 i x B \,a^{2} b}{a^{4}-2 a^{2} b^{2}+b^{4}}-\frac {2 i x B \,b^{3}}{a^{4}-2 a^{2} b^{2}+b^{4}}-\frac {i x B}{a -b}+\frac {i x B}{a +b}-\frac {\ln \left ({\mathrm e}^{i x}+\frac {i a A +\sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{A b}\right ) B b}{\left (a +b \right ) \left (a -b \right )}+\frac {\ln \left ({\mathrm e}^{i x}+\frac {i a A +\sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{A b}\right ) \sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{\left (a +b \right ) \left (a -b \right )}-\frac {\ln \left ({\mathrm e}^{i x}+\frac {i a A -\sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{A b}\right ) B b}{\left (a +b \right ) \left (a -b \right )}-\frac {\ln \left ({\mathrm e}^{i x}+\frac {i a A -\sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{A b}\right ) \sqrt {-A^{2} a^{2}+A^{2} b^{2}}}{\left (a +b \right ) \left (a -b \right )}+\frac {B \ln \left ({\mathrm e}^{i x}+i\right )}{a -b}-\frac {B \ln \left ({\mathrm e}^{i x}-i\right )}{a +b}\) \(361\)

input
int((A+B*sec(x))/(a+b*sin(x)),x,method=_RETURNVERBOSE)
 
output
2*A/(a^2-b^2)^(1/2)*arctan(1/2*(2*a*tan(1/2*x)+2*b)/(a^2-b^2)^(1/2))+B*(1/ 
(2*a-2*b)*ln(1+sin(x))-1/(2*a+2*b)*ln(sin(x)-1)-b/(a-b)/(a+b)*ln(a+b*sin(x 
)))
 
3.1.8.5 Fricas [A] (verification not implemented)

Time = 3.50 (sec) , antiderivative size = 278, normalized size of antiderivative = 2.84 \[ \int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx=\left [-\frac {B b \log \left (-b^{2} \cos \left (x\right )^{2} + 2 \, a b \sin \left (x\right ) + a^{2} + b^{2}\right ) + \sqrt {-a^{2} + b^{2}} A \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2} + 2 \, {\left (a \cos \left (x\right ) \sin \left (x\right ) + b \cos \left (x\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right ) - {\left (B a + B b\right )} \log \left (\sin \left (x\right ) + 1\right ) + {\left (B a - B b\right )} \log \left (-\sin \left (x\right ) + 1\right )}{2 \, {\left (a^{2} - b^{2}\right )}}, -\frac {B b \log \left (-b^{2} \cos \left (x\right )^{2} + 2 \, a b \sin \left (x\right ) + a^{2} + b^{2}\right ) + 2 \, \sqrt {a^{2} - b^{2}} A \arctan \left (-\frac {a \sin \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (x\right )}\right ) - {\left (B a + B b\right )} \log \left (\sin \left (x\right ) + 1\right ) + {\left (B a - B b\right )} \log \left (-\sin \left (x\right ) + 1\right )}{2 \, {\left (a^{2} - b^{2}\right )}}\right ] \]

input
integrate((A+B*sec(x))/(a+b*sin(x)),x, algorithm="fricas")
 
output
[-1/2*(B*b*log(-b^2*cos(x)^2 + 2*a*b*sin(x) + a^2 + b^2) + sqrt(-a^2 + b^2 
)*A*log(((2*a^2 - b^2)*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2 + 2*(a*cos(x)*s 
in(x) + b*cos(x))*sqrt(-a^2 + b^2))/(b^2*cos(x)^2 - 2*a*b*sin(x) - a^2 - b 
^2)) - (B*a + B*b)*log(sin(x) + 1) + (B*a - B*b)*log(-sin(x) + 1))/(a^2 - 
b^2), -1/2*(B*b*log(-b^2*cos(x)^2 + 2*a*b*sin(x) + a^2 + b^2) + 2*sqrt(a^2 
 - b^2)*A*arctan(-(a*sin(x) + b)/(sqrt(a^2 - b^2)*cos(x))) - (B*a + B*b)*l 
og(sin(x) + 1) + (B*a - B*b)*log(-sin(x) + 1))/(a^2 - b^2)]
 
3.1.8.6 Sympy [F]

\[ \int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx=\int \frac {A + B \sec {\left (x \right )}}{a + b \sin {\left (x \right )}}\, dx \]

input
integrate((A+B*sec(x))/(a+b*sin(x)),x)
 
output
Integral((A + B*sec(x))/(a + b*sin(x)), x)
 
3.1.8.7 Maxima [F(-2)]

Exception generated. \[ \int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx=\text {Exception raised: ValueError} \]

input
integrate((A+B*sec(x))/(a+b*sin(x)),x, algorithm="maxima")
 
output
Exception raised: ValueError >> Computation failed since Maxima requested 
additional constraints; using the 'assume' command before evaluation *may* 
 help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?` f 
or more de
 
3.1.8.8 Giac [A] (verification not implemented)

Time = 0.33 (sec) , antiderivative size = 116, normalized size of antiderivative = 1.18 \[ \int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx=-\frac {B b \log \left (a \tan \left (\frac {1}{2} \, x\right )^{2} + 2 \, b \tan \left (\frac {1}{2} \, x\right ) + a\right )}{a^{2} - b^{2}} + \frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )} A}{\sqrt {a^{2} - b^{2}}} + \frac {B \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) + 1 \right |}\right )}{a - b} - \frac {B \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) - 1 \right |}\right )}{a + b} \]

input
integrate((A+B*sec(x))/(a+b*sin(x)),x, algorithm="giac")
 
output
-B*b*log(a*tan(1/2*x)^2 + 2*b*tan(1/2*x) + a)/(a^2 - b^2) + 2*(pi*floor(1/ 
2*x/pi + 1/2)*sgn(a) + arctan((a*tan(1/2*x) + b)/sqrt(a^2 - b^2)))*A/sqrt( 
a^2 - b^2) + B*log(abs(tan(1/2*x) + 1))/(a - b) - B*log(abs(tan(1/2*x) - 1 
))/(a + b)
 
3.1.8.9 Mupad [B] (verification not implemented)

Time = 20.04 (sec) , antiderivative size = 755, normalized size of antiderivative = 7.70 \[ \int \frac {A+B \sec (x)}{a+b \sin (x)} \, dx=\frac {B\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )+1\right )}{a-b}-\frac {B\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )-1\right )}{a+b}-\frac {\ln \left (32\,A\,B^2\,a^2-32\,A^2\,B\,a^2+\frac {\left (A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,b^3+B\,a^2\,b\right )\,\left (32\,a\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (A^2\,a^2+A^2\,b^2-4\,A\,B\,b^2+B^2\,a^2+3\,B^2\,b^2\right )+64\,A^2\,a^2\,b+32\,B^2\,a^2\,b-\frac {\left (A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,b^3+B\,a^2\,b\right )\,\left (32\,A\,a^4+32\,B\,a^4-32\,A\,a^2\,b^2+64\,B\,a^2\,b^2+32\,a\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,A\,a^2-2\,A\,b^2+4\,B\,a^2-B\,b^2\right )-\frac {96\,a\,b\,\left (a+b\,\mathrm {tan}\left (\frac {x}{2}\right )\right )\,\left (A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,b^3+B\,a^2\,b\right )}{a^2-b^2}\right )}{{\left (a^2-b^2\right )}^2}-64\,A\,B\,a^2\,b\right )}{{\left (a^2-b^2\right )}^2}-32\,B\,a\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,{\left (A-B\right )}^2\right )\,\left (A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,b^3+B\,a^2\,b\right )}{a^4-2\,a^2\,b^2+b^4}+\frac {\ln \left (32\,A\,B^2\,a^2-32\,A^2\,B\,a^2-\frac {\left (B\,b^3+A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,a^2\,b\right )\,\left (32\,a\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (A^2\,a^2+A^2\,b^2-4\,A\,B\,b^2+B^2\,a^2+3\,B^2\,b^2\right )+64\,A^2\,a^2\,b+32\,B^2\,a^2\,b+\frac {\left (B\,b^3+A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,a^2\,b\right )\,\left (32\,A\,a^4+32\,B\,a^4-32\,A\,a^2\,b^2+64\,B\,a^2\,b^2+32\,a\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (2\,A\,a^2-2\,A\,b^2+4\,B\,a^2-B\,b^2\right )+\frac {96\,a\,b\,\left (a+b\,\mathrm {tan}\left (\frac {x}{2}\right )\right )\,\left (B\,b^3+A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,a^2\,b\right )}{a^2-b^2}\right )}{{\left (a^2-b^2\right )}^2}-64\,A\,B\,a^2\,b\right )}{{\left (a^2-b^2\right )}^2}-32\,B\,a\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,{\left (A-B\right )}^2\right )\,\left (B\,b^3+A\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}-B\,a^2\,b\right )}{a^4-2\,a^2\,b^2+b^4} \]

input
int((A + B/cos(x))/(a + b*sin(x)),x)
 
output
(B*log(tan(x/2) + 1))/(a - b) - (B*log(tan(x/2) - 1))/(a + b) - (log(32*A* 
B^2*a^2 - 32*A^2*B*a^2 + ((A*(-(a + b)^3*(a - b)^3)^(1/2) - B*b^3 + B*a^2* 
b)*(32*a*tan(x/2)*(A^2*a^2 + A^2*b^2 + B^2*a^2 + 3*B^2*b^2 - 4*A*B*b^2) + 
64*A^2*a^2*b + 32*B^2*a^2*b - ((A*(-(a + b)^3*(a - b)^3)^(1/2) - B*b^3 + B 
*a^2*b)*(32*A*a^4 + 32*B*a^4 - 32*A*a^2*b^2 + 64*B*a^2*b^2 + 32*a*b*tan(x/ 
2)*(2*A*a^2 - 2*A*b^2 + 4*B*a^2 - B*b^2) - (96*a*b*(a + b*tan(x/2))*(A*(-( 
a + b)^3*(a - b)^3)^(1/2) - B*b^3 + B*a^2*b))/(a^2 - b^2)))/(a^2 - b^2)^2 
- 64*A*B*a^2*b))/(a^2 - b^2)^2 - 32*B*a*b*tan(x/2)*(A - B)^2)*(A*(-(a + b) 
^3*(a - b)^3)^(1/2) - B*b^3 + B*a^2*b))/(a^4 + b^4 - 2*a^2*b^2) + (log(32* 
A*B^2*a^2 - 32*A^2*B*a^2 - ((B*b^3 + A*(-(a + b)^3*(a - b)^3)^(1/2) - B*a^ 
2*b)*(32*a*tan(x/2)*(A^2*a^2 + A^2*b^2 + B^2*a^2 + 3*B^2*b^2 - 4*A*B*b^2) 
+ 64*A^2*a^2*b + 32*B^2*a^2*b + ((B*b^3 + A*(-(a + b)^3*(a - b)^3)^(1/2) - 
 B*a^2*b)*(32*A*a^4 + 32*B*a^4 - 32*A*a^2*b^2 + 64*B*a^2*b^2 + 32*a*b*tan( 
x/2)*(2*A*a^2 - 2*A*b^2 + 4*B*a^2 - B*b^2) + (96*a*b*(a + b*tan(x/2))*(B*b 
^3 + A*(-(a + b)^3*(a - b)^3)^(1/2) - B*a^2*b))/(a^2 - b^2)))/(a^2 - b^2)^ 
2 - 64*A*B*a^2*b))/(a^2 - b^2)^2 - 32*B*a*b*tan(x/2)*(A - B)^2)*(B*b^3 + A 
*(-(a + b)^3*(a - b)^3)^(1/2) - B*a^2*b))/(a^4 + b^4 - 2*a^2*b^2)